<?php

namespace Home\Controller;

use Home\Core\CommandSDK;

class AreaListController extends BaseController
{
    /**
     * 检索区域列表
     */
    public function area_list()
    {
        $param = I('get.');
        $param['name']=I('get.name');//区域名称
        if(empty(I('get.pageid'))){
            $param['pageid']=1;
        }else{
            $param['pageid']=$_GET['pageid'];
        }
        if(empty(I('get.pagecount'))){
            $param['pagecount']=10;
        }else{
            $param['pagecount']=$_GET['pagecount'];
        }
        $pageid=$param['pageid'];
        $pagecount=$param['pagecount'];
        $sdk = new CommandSDK();
        $return = $this->http_request($sdk::getAreaLists, $param, 'GET');
        $totnum=$return->totnum;
        $pagenum=$totnum/$pagecount;
        $array = json_decode(json_encode($return), true);
        $this->assign('pageid', $pageid);//页数
        $this->assign('pagecount', $pagecount);//每页显示条数
        $this->assign('pagenum', $pagenum);//总页数
        $this->assign('totnum', $totnum); //总条数
        $this->assign('array', $array);
        $this->assign('param',$param);   // 搜索条件
        $this->display();
    }
    /**
     * 增加区域
     */
    public function AddArea_post()
    {
        $param = I('post.');
        $sdk = new CommandSDK();
        $return = $this->http_request($sdk::AddArea, $param, 'GET');
        $array = json_decode(json_encode($return), true);
        $array['msg']=$sdk::error_code[$return->result];
        $this->ajaxReturn($array);
    }
    /**
     * 修改区域
     */

    public function ModifyArea_post()
    {
        $param = I('post.');
        $sdk = new CommandSDK();
        $return = $this->http_request($sdk::ModifyArea, $param, 'GET');
        $array = json_decode(json_encode($return), true);
        $array['msg']=$sdk::error_code[$return->result];
        $this->ajaxReturn($array);
    }
    /**
     * 删除区域
     */

    public function DelArea_post()
    {
        $param = I('post.');
        $sdk = new CommandSDK();
        $return = $this->http_request($sdk::DelArea, $param, 'GET');
        $array = json_decode(json_encode($return), true);
        $array['msg']=$sdk::error_code[$return->result];
        $this->ajaxReturn($array);
    }


}
